/**
rid: 118613
user: 04172604ZDY
time: 2017-11-26 14:07:14
result: Runtime Error 
*/
//以为vector的resize存在问题,更换方式
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

vector<vector<float> > T;
vector<short > aims;
vector<vector<float> > data;
float result;

float deal(short self, int aimCount) {
    if(data[self][aimCount-1] != -1)
        return data[self][aimCount-1];
    short aim = aims[aims.size()-aimCount];
    data[self][aimCount-1] = T[self][aim];
    if(aimCount > 1) {
        float orig = deal(self, aimCount - 1);
        float replace = deal(aim, aimCount - 1);
        data[self][aimCount - 1] *= (orig > replace ? orig : replace);
    }
    if(data[self][aimCount-1] < result)
        return 0;
    return data[self][aimCount-1];
}

int main() {
    int n;
    while(cin >> n) {
        int R = n*(n-1)*(n-2)/6;//max 120
        //init T
        T.clear();
        T.reserve(R);
        for(int i = 0; i < R; i++) {
            vector<float> t;
            t.reserve(R);
            float t0;
            for(int j = 0; j < R; j++) {
                cin >> t0;
                t.push_back(t0);
            }
            T.push_back(t);
        }
        //init aims
        int aimCount;
        cin >> aimCount;
        aims.clear();
        aims.reserve(aimCount);
        float t1;
        for(int i = 0; i < aimCount; i++) {
            cin >> t1;
            aims.push_back(t1);
        }
        //init data
        data.clear();
        data.reserve(R);
        for(int i = 0; i < R; i++) {
            vector<float> t2;
            t2.reserve(aimCount);
            for(int j = 0; j < aimCount; j++)
                t2.push_back(-1);
            data.push_back(t2);
        }
        //deal with data
        result = 0;
        for(int i = 0; i < R; i++) {
            float cache = deal(i, aimCount);
            if(cache > result)
                result = cache;
        }
        cout << std::fixed << setprecision(6) << result << endl;
    }
    return 0;
}